package com.example.nonggo.viewpager;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.nonggo.fragment.HomeFragment;


import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.lifecycle.Lifecycle;
import java.util.List;

public class VerticalPagerAdapter extends FragmentStateAdapter {

    List<Fragment> fragments;

    public VerticalPagerAdapter( FragmentManager fragmentManager, Lifecycle lifecycle, List<Fragment> fragments) {
        super(fragmentManager,lifecycle);
        this.fragments = fragments;
    }




//    @NonNull
//    @Override
//    public Fragment getItem(int position) {
//        // 返回对应的 Fragment 实例
//        return  fragments.get(position);
//    }
//
//
//
//    @Override
//    public int getCount() {
//        return fragments.size();
//    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return fragments.get(position);
    }

    @Override
    public int getItemCount() {
        return fragments.size();
    }
}

